{/* LAYOUT模板 */}
<layout name="layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}
<js href="__PUBLIC__/js/admin/listTable.js"/>
<js href="__PUBLIC__/js/admin/js.util.js"/>
<css href="__CSS__/qs-table-1.0.css"/> <!-- tableUI -->
<css href="__PUBLIC__/css/admin/common.css"/>
<css href="__PUBLIC__/css/jquery-ui.css" />
<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
<js href="__PUBLIC__/js/core/plugins.js"/>
{/* import js,css */}
<!-- [position] -->
<include file="Template:position"/>
<!-- [position] -->
<div id="loading" class="hide"><!--加载条--></div>

<include file="Attribute:l_attribute_filter"/>

<form method="post" action="" name="listForm">
	<div class="list-div" id="listDiv">
		<include file="Attribute:l_attribute_list"/>
	</div>
</form>

<script>
	/*删除数据*/
	listTable.remove = function(id,tips,url){
		var ajaxUrl = ( typeof url != 'undefined' ) ? url : listTable.url;	
		if(confirm(tips)){
			$.extend(listTable.opt,{
				 url:'__URL__/ajax_attribute',
				 type:'post',
				 dataType:'json',
				 data:{id:id,action:'del'},
				 beforeSend:function(){
					$('#loading').QLoading({text:'操作中...',modal:false,status:'open'});
				},
				 success:function(msg){				
					if(msg.data == '1'){											
						$('#tr_' + id).remove();
						$('#loading').QLoading({img:'happy',text:'操作成功',modal:false,status:'close',time:1.5});
					}
					else{
						$('#loading').QLoading({img:'sad',text:'操作失败',modal:false,status:'close',time:1.5});
					}					
				 }		
			});
			$.ajax(listTable.opt);		
		}	
	}
	$(document).ready(function(){
		/* 隔行变色 */
		$('#attribute-list-table').tableUI();
		/* Initialize Url */
		listTable.init('__URL__/ajax_attribute');				
	});	
	
	function searchAttr(goodsType){
		listTable.filter.goods_type = goodsType;
		//listTable.loadList();
		$.ajax({
			url:'__URL__/attribute_list',
			type:'post',
			dataType:'json',
			data:{goods_type:goodsType,action:'select'},
			beforeSend:function(){
				$('#loading').QLoading({text:'操作中...',modal:false,status:'open'});
			},
			success:function(msg){
				if(msg.data == '1'){
					$('#listDiv').html('').html(msg.info);
					$('#loading').QLoading({img:'happy',text:'操作成功',modal:false,status:'close',time:1.5});				
				}
				else{
					$('#loading').QLoading({img:'sad',text:'操作失败',modal:false,status:'close',time:1.5});
				}
				/*隔行变色*/
				$('#attribute-list-table').tableUI();
			}
		});
	}
	/*全选
	listTable.selectAll	= function(obj,name){
		//alert(name);
	}*/
	listTable.removeAll	= function(id){
		var obj	= $('#'+id);
		var input_list = obj.find("input[data=id]");
		var values	= new Array();
		input_list.each(function(n){
			values[n] = $(this).val();
		});
		/*批量删除属性*/
		$.ajax({
			url:'__URL__/ajax_attribute',
			type:'post',
			dataType:'json',
			data:{action:'batch_del',ids:values},
			beforeSend:function(){
				$('#loading').QLoading({text:'操作中...',modal:false,status:'open'});
			},
			success:function(msg){
				if(msg.data == '1'){
					$('#attribute-list-table').find('tr.data').each(function(){
						$(this).remove();
					});
					$('#loading').QLoading({img:'happy',text:'操作成功',modal:false,status:'close',time:1.5});				
				}
				else{
					$('#loading').QLoading({img:'sad',text:'操作失败',modal:false,status:'close',time:1.5});
				}
				/*隔行变色*/
				$('#attribute-list-table').tableUI();
			}
		});
	}
</script>


